package com.changyue.util;

/**
 * @author zpp
 * des:点击事件相关处理
 */
public class ClickUtils {
    private static final int LESS_MIN_DELAY_TIME = 200;
    private static final int MIN_DELAY_TIME = 1000;
    private static long lastClickTime;

    /**
     * 限制按钮多次点击一秒之内不能重复点击
     */
    public static boolean isFastClick() {
        boolean flag = true;
        long currentClickTime = System.currentTimeMillis();
        if ((currentClickTime - lastClickTime) >= MIN_DELAY_TIME) {
            flag = false;
        }
        lastClickTime = currentClickTime;
        return flag;
    }

    public static boolean isLessFastClick() {
        boolean flag = true;
        long currentClickTime = System.currentTimeMillis();
        if ((currentClickTime - lastClickTime) >= LESS_MIN_DELAY_TIME) {
            flag = false;
        }
        lastClickTime = currentClickTime;
        return flag;
    }

    private static int aculClickTime = 0;
    public static boolean isContiune5Click(){
        boolean flag = true;
        long currentClickTime = System.currentTimeMillis();
        if ((currentClickTime - lastClickTime) >= MIN_DELAY_TIME) {
            flag = false;
            aculClickTime = 0;
        } else {
            aculClickTime++;
            if(aculClickTime > 4) {
                aculClickTime = 0;
            } else {
                flag = false;
            }
        }
        lastClickTime = currentClickTime;
        return flag;
    }

}
